Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

form-data-encoder

Package Overview
Dependencies
Maintainers
1
Versions
39
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

form-data-encoder

Encode FormData content into the multipart/form-data format

  • 2.1.4
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
5.7M
decreased by-6.46%
Maintainers
1
Weekly downloads
 
Created

What is form-data-encoder?

The form-data-encoder package is designed to encode FormData objects into a variety of formats suitable for HTTP transmission. It is particularly useful for preparing multipart/form-data payloads without relying on the browser's native FormData implementation, which can be beneficial in non-browser environments like Node.js.

What are form-data-encoder's main functionalities?

Encoding FormData for multipart/form-data

This feature allows you to encode a FormData object into a multipart/form-data format, which is suitable for HTTP requests. The code sample demonstrates how to create a FormData object, append fields and files, and then use the FormDataEncoder to encode the data and retrieve the necessary headers for an HTTP request.

const { FormDataEncoder } = require('form-data-encoder');
const { FormData, File } = require('formdata-node');

const formData = new FormData();
formData.append('field', 'value');
formData.append('file', new File(['content'], 'file.txt'));

const encoder = new FormDataEncoder(formData);

// You can now use encoder to get headers and read the encoded form data
const headers = encoder.headers;
const body = Readable.from(encoder);

Streaming encoded data

This feature is useful for streaming the encoded form data, which can be helpful when dealing with large files or when you want to send the data in chunks over a network. The code sample shows how to iterate over the encoder to handle each chunk of data.

const { FormDataEncoder } = require('form-data-encoder');
const { FormData } = require('formdata-node');

const formData = new FormData();
formData.append('field', 'value');

const encoder = new FormDataEncoder(formData);

// Stream the encoded form data
for await (const chunk of encoder) {
  // Handle each chunk of data
}

Other packages similar to form-data-encoder

Keywords

FAQs

Package last updated on 24 Nov 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc